<?php
//require_once  __DIR__ . '/includes/authenticate.php';

if (isset($_POST['playerID'])) {
	
	include_once './db_bb_connect.php';

	$playerID = $_POST['playerID'];
	$category = $_POST['category'];
	$fulltext = $_POST['fulltext'];
	$date = $_POST['date'];

	$sql = "INSERT INTO profiles (playerID, category, content, date)
	VALUES ('$playerID', '$category', '$fulltext', '$date' )";

	if ($db->query($sql)){

			$sql = "SELECT firstname, lastname 
			FROM users
			WHERE user_key = '$playerID'";

			$result = $db->query($sql);
			$row = $result->fetch_assoc();
			$firstname = $row['firstname'];
			$lastname = $row['lastname'];

			echo "<br><center> Data of $firstname $lastname succesfully added! </center>";
	} else {
		echo "Something went wrong, data not added";
		echo "Error: " . $sql . "<br>" . $db->error;
	};


}



?>